<?php 
$negocio = $this->pedido->getNegocio();
$productos = $this->pedido->getProductos();
$promociones = $this->pedido->getPromociones();
$direccion = $this->pedido->getDireccion() ;

$organized = $this->organizeProducts( $productos, $promociones );
$organized = current( $organized );

$productos	= $organized['productos'];
$promociones= $organized['promociones'];

$negocioUrl	= $this->url(array('negocioUrl'=>$negocio->url), 'negocio');

?>
<div class="topBox myCart order">
	
	<?php echo $this->MyFlashMessenger();?>
	<img src="/img/order-status-<?php echo $this->pedido->estado?>.png" title="<?php echo $this->translate("orderStatusDesc{$this->pedido->estado}");?>" alt="<?php echo $this->translate("orderStatusDesc{$this->pedido->estado}");?>" class="orderStatus" />
	<h1  class="title"><?php echo $this->translate('order')?> <?php echo $this->pedido->idPedido?> - <?php echo $this->translate("orderStatus{$this->pedido->estado}");?></h1>
	
	    
	
		<div class="orderTypeContainer">
			<label><?php echo $this->translate('orderType')?>:</label>
			<?php echo $this->translate( ($this->pedido->isDelivery() ? 'delivery' : 'pickup' ))?>
		</div>
	
		<?php 
		
		$fecha = new Zend_Date( $this->pedido->fechaEntrega );
		
		if( $this->pedido->isDelivery() ){
			
			echo '<div id="deliveryAddressContainer-'.$negocio->idNegocio.'" class="deliveryAddressContainer"><label>'.$this->translate('deliveryAddress').':</label>';
			echo $direccion;
			echo '</div>';
			
			echo '<div id="deliveryTimeContainer-'.$negocio->idNegocio.'" class="deliveryTimeContainer"><label>'.$this->translate('deliveryHour').':</label>';
			echo $fecha->toString(Zend_Date::DATETIME_MEDIUM);
			echo '</div>';
			
			echo '<div id="deliveryPrice-'.$negocio->idNegocio.'" class="deliveryPriceContainer">
					<label>'.$this->translate('deliveryPrice').':</label> 
					<span>'. $this->precio( $this->pedido->costoEnvio ).'</span>
				</div>';
			
			
		} else {
			
			echo '<div id="pickupTimeContainer-'.$negocio->idNegocio.'" class="pickupTimeContainer" ><label>'.$this->translate('pickupTime').':</label>';
			echo $fecha->toString(Zend_Date::DATETIME_MEDIUM);
			echo '</div>';
			
		}
		
		?>
</div>
<div class="bottomBox myCart">	
	
	<p class="title"><?php echo $this->translate('yourOrderAt')?>: </p>
	<p class="title"><a href="<?php echo $negocioUrl?>"><?php echo $this->escape( $negocio->nombre )?></a></p>
	
	<div class="pedido" id="p_<?=$negocio->idNegocio?>">
			<table class="listadoProductos">
				<thead>
					<tr>
						<th><?php echo $this->translate('item')?></th>
						<th><?php echo $this->translate('price')?></th>
						<th><?php echo $this->translate('quantityShort')?></th>
						<th><?php echo $this->translate('subtotal')?></th>
					</tr>		
				</thead>
				<tbody>
				<?php 
				foreach ($productos as $categoria=>$p){
					
					echo "<tr><td colspan='4' class='category'>{$categoria}</td></tr>";
					
					foreach ($p as $producto){
							?>
					<tr id="p_<?php echo $producto->idProducto?>">
						<td class="name"><?php echo $producto->nombre?><?php echo $this->productoOpciones( $producto->getOpcionesPedidas() );?></td>
						<td class="price"><?php echo $this->precio($producto->getPrecio())?></td>
						<td class="quantity"><?php echo $producto->cantidad?></td>
						<td class="subTotal"><?php echo $this->precio( $producto->getPrecioTotal())  ?></td>
					</tr>
					<?php	
					}
				}
				
				if ( !empty($promociones)){
					echo "<tr><td colspan='4' class='category'>".$this->translate('promotions')."</td></tr>";
				}
				
				foreach ($promociones as $promocion){
					?>
					<tr id="promo_<?php echo $promocion->getKey()?>">
						<td class="name"><?php echo $promocion->nombre?>
							<?php echo $this->promoProductos( $promocion->getProductosPedidos() );?>
						</td>
						<td class="price"><?php echo $this->precio($promocion->getPrecio())?></td>
						<td class="quantity"><?php echo $promocion->cantidad?></td>
						<td class="subTotal"><?php echo $this->precio($promocion->getPrecioTotal())  ?></td>
					</tr>
					<?php	
				}
				?>
				</tbody>
				<tfoot>
					<tr class="deliveryPrice" >
						<td colspan="3"><?php echo $this->translate('deliveryPrice')?></td>
						<td class="deliveryPrice-<?php echo $negocio->idNegocio?>"><span><?php echo $this->precio( $this->pedido->costoEnvio )?></span></td>
					</tr>
					<tr>
						<td colspan="3" class="totalPriceLabel"><?php echo $this->translate('total')?></td>
						<td class="totalPrice totalPrice-<?php echo $negocio->idNegocio?>"><span><?php echo $this->precio($this->pedido->precioFinal)?></span></td>
					</tr>
				
				</tfoot>
			</table>
		</div>

</div>
<?php 

$this->renderToPlaceholder('side/tip-vote.phtml','side');

if ( isset($this->whiteLabelType )){
    $this->renderToPlaceholder('negocio/side-white-label.phtml','side');
}


$this->headTitle()->append( sprintf($this->translate('meta-title-change-order'), $this->pedido->getId()) );



